/*
Arduino 串口文档
https://www.arduino.cc/reference/en/language/functions/communication/serial/

*/

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266WebServer.h>

ESP8266WiFiMulti wifiMulti;
ESP8266WebServer server(8080);

void setup() {
  Serial.begin(9600);

  wifiMulti.addAP("wsm","WSM19900509");
  wifiMulti.addAP("taichi-maker2", "87654321"); 
  wifiMulti.addAP("wsm", "WSM19900509"); 

  Serial.println("Connecting ...");    
  while (wifiMulti.run() != WL_CONNECTED) {  
    delay(1000);  
    Serial.println(wifiMulti.run());        
  } 


  Serial.print("Connected to ");  
  Serial.print(WiFi.SSID());
  Serial.print(WiFi.localIP());

  server.begin();
  server.on("/hello",handleRequest);
   server.on("/json",handleJson);

}

void handleRequest(){
server.send(200,"text/plain","hello world");
}

void handleJson(){
server.send(200,"application/json","{'h':'l'}");
}

void loop() {
  server.handleClient();

}
